package main

import (
	"sync/atomic"
	"fmt"
	"time"
)

/*
   @Time : 2019/6/25 18:14 
   @Author : ff
   @DESC   : 
*/

func main() {
	var num int32
	num = 2
	for {
		if (atomic.CompareAndSwapInt32(&num,10,0)) {
			fmt.Println("The second number has gone to zero.")
			break
		}
		num ++
		time.Sleep(time.Millisecond * 500)
	}
}